using NetMicro.Core.ApiFunction;
using NetMicro.Core.DynamicWebApiController.Dependencies;
using NetMicro.EventBus;
using NetMicro.Trace.Extend;
using Sample.Eventbus;

namespace Sample.Controllers
{
    public class LogController : IDynamicWebApiController
    {
        
        private readonly ILogger<LogController> _logger;
        private readonly IPublisherEvent _publisherEvent;
        public LogController(ILogger<LogController> logger, IPublisherEvent publisherEvent)
        {
            _logger = logger;
            _publisherEvent = publisherEvent;
        }

        public Task<IServiceResult> LogTestEvent()
        {
            _publisherEvent.PublishAsync(new TestEvent
            {
                Msg = "测试信息"
            });
            return Task.FromResult<IServiceResult>(ServiceResult.Success());
        }
        public Task<IServiceResult> LogTest()
        {

            Log.LogInformation<LogController>("测试静态日志");
            _logger.LogInformation("测试普通日志信息");

            return Task.FromResult<IServiceResult>(ServiceResult.Success());
        }
    }
}
